<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html>
<head>
<style>
body{background:url(web/pages/images/main_bg_03.png) repeat;}
.texts {width:380px; border:1}  
.list-content {
    width:850px;
	height:550px;
	font-size:12px;
	text-align:left;
	border:2px solid #92b0c6;
	color:#666;
	display:inline-block;
}
.list_page{
    margin-right:10px;
	width: 842px;
	line-height:18px;
	font-size:12px;
	text-align:right;
	color:#666;
	display:inline;
	float:left; 
}
.list_page_text{
	color:#146185;
	}

.btn02 {
	width:78px;
	height:24px;
	background:url(web/pages/images/btn_list01.png) no-repeat;
	border:none;
	color:#003366;
	cursor:pointer;
	display:inline;
}
.btn03 {
	width:78px;
	height:24px;
	background:url(web/pages/images/btn_list04.png) no-repeat;
	border:none;
	color:#990000;
	cursor:pointer;
	font-weight:bold;
	display:inline;
}
.edit-content {
    width:850px;
	height:550px;
	font-size:12px;
	text-align:left;
	border:2px solid #92b0c6;
	color:#666;
	display:inline-block;
}
.input01{
	width:110px;
	height:20px;
	border:1px solid #a1a1a1;
	}
a{text-decoration:none;color:#666;}
a:hover{color:#FF9900;}
</style>
	<meta charset="utf-8" />
	<title>KindEditor JSP</title>
	<link rel="stylesheet" href="web/kindeditor/themes/default/default.css" />
	<link rel="stylesheet" href="web/kindeditor/plugins/code/prettify.css" />
	<script charset="utf-8" src="web/kindeditor/kindeditor.js"></script>
	<script charset="utf-8" src="web/kindeditor/lang/zh_CN.js"></script>
	<script charset="utf-8" src="web/kindeditor/plugins/code/prettify.js"></script>
	<script type="text/javascript" src="web/pages/js/jquery-1.7.1.min.js"></script>
	<script type="text/javascript">
		KindEditor.ready(function(K) {
			var editor = K.create('textarea[name="content"]', {
				cssPath : 'web/kindeditor/plugins/code/prettify.css',
				uploadJson : 'web/kindeditor/jsp/upload_json.jsp',
				fileManagerJson : 'web/kindeditor/jsp/file_manager_json.jsp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K('#image3').click(function() {
						editor.loadPlugin('image', function() {
							editor.plugin.imageDialog({
								showRemote : false,
								imageUrl : K('#url3').val(),
								clickFn : function(url, title, width, height, border, align) {
									K('#url3').val(url);
									editor.hideDialog();
								}
								
							});
						});
					});
					K('input[name=btnSubmitInfo]').click(function(e) {
						if (confirm("是否确认修改"))  
							{  
							var beginTime = "<s:property value='beginTime'/>";
							var endTime = "<s:property value='endTime'/>";
							var bt = "<s:property value='bt'/>";
								$.ajax({
										type: "POST",
										url: "updateArticle.action?picturePath="+$("#url3").val()+"&beginTime="+beginTime+"&endTime="+endTime+"&bt="+ encodeURI(encodeURI(bt)),
										dateType: "json",
										data: {"articleID": $("#articleid").val(),"classID": $("#classid").val(),"title": $("#title").val(),"author": $("#author").val(), "content": editor.html(),"shortContent": $("#shortContent").val(),"editor": $("#editor").val(),"source": $("#source").val(),"hits": $("#hits").val()},
										success: function(returnedData){
												
												var json = eval( "("+returnedData+")" );
												alert(json.confirmUpd);
												if(json.bt != '')
												{
													var url = "ArticleQuery.action?beginTime="+json.beginTime+"&endTime="+json.endTime+"&bt="+json.bt;
													window.location=encodeURI(encodeURI(url));
												}
												else
												{
													window.location="Articlelist.action?classId="+json.classID;
												}
												
										}
									});
							}  
							else  
							{ 
							return false;
							};	
					});
				}
			});
			
			prettyPrint();
		});
		function textCount(obj,a_limit)
		{
			if (obj.value.length > a_limit) 
			{
			obj.value = obj.value.substring(0,a_limit);
			}
			else 
			{document.all["remLen"].value = obj.value.length;
			}
		}
		function initText(){
			var obj = document.getElementById("shortContent");
			textCount(obj,500);
		}
	</script>
</head>
<body onload="initText()">


  <div class="edit-content"> 
	  <table width="800" cellpadding="2" cellspacing="2">
		<tr><td colspan="10">&nbsp;<input type="button" name="back" id="back"
							value="返回" class="btn03" onclick="history.go(-1)"/></td></tr>
		
		<s:iterator value="detailPage.showArticle" var="val">
			<input type="hidden" id="articleid" value="<s:property value='#val.articleID'/>">
		    <input type="hidden" id="classid" value="<s:property value='#val.classID'/>">	
		<tr>
		  <td colspan="6">标&nbsp;&nbsp;&nbsp;&nbsp;题:&nbsp;<input class="texts" maxlength="100" type="text" id="title" name="title" class="input01" value="<s:property value='#val.title'/>"/>&nbsp;<font size="3" color="red">*</font></td>
		  <td colspan="4">作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;者:&nbsp;&nbsp;<input maxlength="50" type="text" id="author" name="author" class="input01" value="<s:property value='#val.author'/>"/></td>
		</tr>
		<tr>
		  <td colspan="6">来&nbsp;&nbsp;&nbsp;&nbsp;源:&nbsp;<input maxlength="20" type="text" id="source" name="source" class="input01" value="<s:property value='#val.source'/>"/>
		  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		  &nbsp;&nbsp;&nbsp;
		  编&nbsp;&nbsp;&nbsp;&nbsp;辑:&nbsp;<input maxlength="20" type="text" id="editor" name="editor" class="input01" value="<s:property value='#val.editor'/>"/></td>
		  <td colspan="4">创建时间:&nbsp; <input style="background:grey" type="text" id="insertTime" value="<s:date name='#val.insertTime' format='yyyy-MM-dd hh:mm:ss' />" readonly></td>
		</tr>
		<s:if test="#val.basePath==''||#val.basePath==null">
		</s:if>
		<s:else>	
		<tr>
		  <td colspan="6">缩略图:&nbsp;<input class="texts" type="text" id="url3" name="url3" class="input01" value="<s:property value='#val.basePath'/>/<s:property value='#val.fileName'/>"/>
		  <input type="button" name="image3" id="image3" value="选择图片" class="btn02" /></td>
		</tr>
		</s:else>
		</s:iterator>
		<tr><td colspan="10"><div id="J_imageView"></div>&nbsp;</td></tr>
		<tr>
		  <td colspan="10" align="left" valign="top">摘要: <textarea onpropertychange=textCount(this,500) id="shortContent" cols="100" rows="2"><s:property value="#val.shortContent"/></textarea>
		  您已经输入了:<INPUT style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; COLOR: red; BORDER-BOTTOM: 0px" readOnly maxLength=3 size=4 value=0 name=remLen>个字,摘要最多输入500个字符。
		  </td>
	    </tr>
		<tr>
		  <td colspan="10" align="left" valign="top">内容: &nbsp;<font size="3" color="red">*</font>
		  <textarea id="content" name="content" cols="100" rows="6" style="width:700px;height:200px;visibility:hidden;"><s:property value="#val.content" escape="false"/></textarea>
		  </td>
	    </tr>
		<tr><td colspan="10"><input type="button" name="btnSubmitInfo" id="btnSubmitInfo" value="提交内容" class="btn03" /></td>
		<td colspan="10">
						
					</td></tr>
		<tr><td colspan="10">&nbsp;</td></tr>
	  </table> 
</div>


</body>
</html>
